<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

</head>

<body>

<h2>Hello World!</h2>

<input type="button" value="导出excel文件" onclick="exportExcel()">
<input type="button" value="隐藏表单导出excel文件" onclick="exportExcelForm()">

</body>
<script type="text/javascript" src="static/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
function exportExcel() {
	// /download/export
	/* $.ajax({
			type : "post",
			url : "download/export",
			data : null,//将数据转换成json字符串
			//dataType : 'text',
			dataType:"json",      
   			contentType:"application/json",    
			success : function(respdata) {	
				
			}
	}); */
	
	try{ 
        var elemIF = document.createElement("iframe");   
        elemIF.src = "download/export";   
        elemIF.style.display = "none";   
        document.body.appendChild(elemIF);   
    }catch(e){ 

    } 
	
}


function exportExcelForm() {
	var form = $("<form>");
	form.attr("style","display:none");
	form.attr("target","");
	form.attr("method","post");
	form.attr("action", "download/export");
	var input1 = $("<input>");
	input1.attr("type","hidden");
	input1.attr("name","data");
	input1.attr("value","{1:1,2:2,3:3}");
	$("body").append(form);
	form.append(input1);
	form.submit();
	form.remove();
}

</script>


</html>
